import ADQ from "./ADQ";
import LoadADQMoudle from "../Config/LoadADQMoudle";
import ProgressManager from "./ProgressManager";
import { ADQContaniner } from "../DesignMode/ADQContaniner";
import { IEventHandler } from "../Interfaces/IUtils";
import { IRegisterMoudle } from "../Interfaces/IIOC";

/**ADQ 游戏初始化类型 */
export default class ADQInitialize {
  /**
   * 初始化构造函数
   * @param complete 构造完毕回调函数
   * @param loadMoudele 加载自定义模块
   */
  constructor(complete: IEventHandler, loadMoudele?: IRegisterMoudle) {
    this.onEnable(complete, loadMoudele);
  }
  /**游戏管理器初始化 */
  onEnable(complete: IEventHandler, loadMoudele?: IRegisterMoudle): void {
    ADQ.progressManager = new ProgressManager(complete, 0); //初始化进度加载器
    ADQ.container = new ADQContaniner();
    new LoadADQMoudle().Load(ADQ.container);
    if (loadMoudele != null) loadMoudele.Load(ADQ.container);

    ADQ.GameEnvironment && ADQ.GameEnvironment.InitEnvironment();
    ADQ.setContaniner();
  }
}
